package demo01extends;

public class Student {
    private String name;
    private int id;
    static String room;
    private  static int idcounter=0;//学号计数器

    //静态代码块
    static {
        System.out.println("静态代码块");
    }
    public static void myMethod(){
        System.out.println("静态方法");
    }

    public Student(){
        System.out.println("默认构造");
        idcounter++;
    }
    public Student(String name) {

        this.id=++idcounter;
        this.name = name;
        System.out.println(this.name+"的参数构造");
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public static String getRoom() {
        return room;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static void setRoom(String room) {
        Student.room = room;
    }
}
